﻿using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using DomainModel;

namespace DataAccess
{
    class SectionConfiguration : EntityTypeConfiguration<Section>
    {
        public SectionConfiguration()
        {
            Property(p => p.Id).IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            HasKey(p => p.Id);
            Property(p => p.Name).HasMaxLength(200).IsRequired();
            HasOptional(p => p.Parent).WithMany(p => p.Sections).HasForeignKey(p => p.ParentSectionId);
        }
    }
}
